function addMaterialOfRow() {
	var t = document.getElementById("mbody");
	var row = t.insertRow(t.rows.length);
	var i = t.rows.length - 1;
	var col = row.insertCell(0);
	
	col.innerHTML = "<td><input type='hidden' name='bomDetailRow' id='bomDetailRow' /><input  type='checkbox' name='checkbox'/></td>";
	col = row.insertCell(1);	
	col.innerHTML = "<td><input type='hidden'  id='materialId" + i + "' /><input name='materialCode' id='materialCode" + i + "' size='8' ondblclick='openWinMaterial(" + i + ",750,700,0)' /></td>";
	col = row.insertCell(2);
	col.innerHTML = "<td><input name='materialName' id='materialName"+i+"' readonly='true' type='text' size='8'/></td>";
	col = row.insertCell(3);
	col.innerHTML = "<td><input name='spec' id='spec"+i+"' readonly='true' type='text' size='8'/></td>";
	col = row.insertCell(4);
	col.innerHTML = "<td><input name='materialAttribute' id='materialAttribute"+i+"' readonly='true' type='text' size='8'/></td>";
	col = row.insertCell(5);
	col.innerHTML = "<td><input name='assistantAttribute' id='assistantAttribute"+i+"' type='text' size='8'/></td>";
	col = row.insertCell(6);
	col.innerHTML = "<td><input type='hidden'  id='measureUnitId" + i + "'   /><input name='measureUnitName'  readonly='true' id='measureUnitName"+i+"' ondblclick='openWinMeasureUnit(" + i + ",750,700,0)'  onpropertychange='getCostInfo("+i+")' type='text' size='8'/></td>";
	col = row.insertCell(7);
	col.innerHTML = "<td><input name='basicMeasureUnitName' id='basicMeasureUnitName"+i+"' readonly='true' type='text'size='7'/></td>";
	col = row.insertCell(8);
	col.innerHTML = "<td><input name='basicCost' id='basicCost"+i+"'  readonly='true' type='text'size='7'/></td>";
	col = row.insertCell(9);
	col.innerHTML = "<td><input name='cost' id='cost"+i+"' type='text' size='7' onchange='getBasicCostInfo("+i+")' /></td>";
	col = row.insertCell(10);
	col.innerHTML = "<td><input name='lossPercent' id='lossPercent"+i+"' type='text' size='8'/></td>";
	col = row.insertCell(11);
	col.innerHTML = "<td><input name='usedState' id='usedState"+i+"' readonly='true' type='text' size='8'/></td>";
	col = row.insertCell(12);
	col.innerHTML = "<td><input type='hidden'  id='storageId" + i + "' /><input name='storageName' id='storageName"+i+"' ondblclick='openWinStorage(" + i + ",750,700,0)' type='text' size='7'/></td>";
}
function openWinMaterial(index, width, height, scroll) {
	var truelink = "selectMultiMaterial.action?rowIndex="+index;
	openWin(truelink, null, width, height, scroll);
}

function openWinMeasureUnit(index, width, height, scroll){
	var truelink = "selectMeasure.action?rowIndex="+index;
	openWin(truelink, null, width, height, scroll);
}

function openWinStorage(index, width, height, scroll){
	var truelink = "selectStorage.action?rowIndex="+index;
	openWin(truelink, null, width, height, scroll);
}

function childToParentForMaterial(index,id, childId, name, childName, code, childCode, materialAttribute, childMaterialAttribute, spec, childSpec,storageName,childStorageName,measureUnitName,childMeasureUnitName,basicMeasureUnitName,childBasicMeasureUnitName,storageId,childStorageId,measureUnitId,childMeasureUnitId) {
	var t = window.opener.document.getElementById("mbody");	
	
	var parentId = window.opener.document.getElementById(id + index);
	var parentName = window.opener.document.getElementById(name+ index);
	var parentCode = window.opener.document.getElementById(code + index);
	var parentMaterialAttribute = window.opener.document.getElementById(materialAttribute+ index);
	var parentSpec = window.opener.document.getElementById(spec+ index);
	var parentStorageName =  window.opener.document.getElementById(storageName+ index);
	var parentMeasureUnitName =  window.opener.document.getElementById(measureUnitName+ index);
	var parentBasicMeasureUnitName =  window.opener.document.getElementById(basicMeasureUnitName+ index);
	var parentCost =  window.opener.document.getElementById('cost'+ index);
	var parentBasicCost =  window.opener.document.getElementById('basicCost'+ index);
	var parentUsedState =  window.opener.document.getElementById('usedState'+ index);
	var parentStorageId =  window.opener.document.getElementById('storageId'+ index);
	var parentMeasureUnitId = window.opener.document.getElementById('measureUnitId'+ index);
	parentId.value = childId;
	parentName.value = childName;
	parentCode.value = childCode;
	parentMaterialAttribute.value = childMaterialAttribute;
	parentSpec.value = childSpec;
	parentStorageName.value = childStorageName;
	parentMeasureUnitName.value = childMeasureUnitName;
	parentBasicMeasureUnitName.value = childBasicMeasureUnitName;
	parentCost.value = '1.00';
	parentBasicCost.value = '1.00';
	parentUsedState.value = '使用';
	parentStorageId.value=childStorageId;
	parentMeasureUnitId.value = childMeasureUnitId;
	window.close();
}




function multiChildToParent(index,parentId, childId, parentName, childName){
		if (window.opener) {
			var pId = window.opener.document.getElementById(parentId+index);
			if (pId != null) {
				pId.value = childId;
			}
			var pName = window.opener.document.getElementById(parentName+index);
			if (pName != null) {
				pName.value = childName;
			}
			window.close();
		}
}



